package me.riddhimanadib.formmaster.viewholder;

import android.content.Context;
import android.content.DialogInterface;
import android.graphics.BitmapFactory;
import android.view.View;

import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.widget.AppCompatEditText;
import androidx.appcompat.widget.AppCompatImageView;
import androidx.appcompat.widget.AppCompatTextView;
import me.riddhimanadib.formmaster.R;
import me.riddhimanadib.formmaster.listener.ReloadListener;
import me.riddhimanadib.formmaster.model.BaseFormElement;
import me.riddhimanadib.formmaster.model.FormElementPickerImage;
import me.riddhimanadib.formmaster.model.FormElementPickerSingle;

/**
 * Created by Riddhi - Rudra on 30-Jul-17.
 */

public class FormElementPickerImageViewHolder extends BaseViewHolder {

    private AppCompatTextView      mTextViewTitle;
    private AppCompatImageView     mImageView;
    private ReloadListener         mReloadListener;
    private BaseFormElement        mFormElement;
    private FormElementPickerImage mFormElementPickerSingle;
    private int                    mPosition;

    public FormElementPickerImageViewHolder(View v, Context context, ReloadListener reloadListener) {
        super(v);
        mTextViewTitle = v.findViewById(R.id.formElementTitle);
        mImageView = v.findViewById(R.id.formElementImage);
        mReloadListener = reloadListener;
    }

    @Override
    public void bind(final int position, BaseFormElement formElement, final Context context) {
        mFormElement = formElement;
        mPosition = position;
        mFormElementPickerSingle = (FormElementPickerImage) mFormElement;

        mTextViewTitle.setText(formElement.getTitle());
       String pathName;
       mImageView.setImageBitmap(BitmapFactory.decodeFile(mFormElementPickerSingle.getImage()));
    }
}
